home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 1753 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.3 KB

  1. Path: chronicle.mti.sgi.com!news
  2. From: austern@isolde.mti.sgi.com (Matt Austern)
  3. Newsgroups: comp.lang.c++
  4. Subject: Re: Name-mangling standard
  5. Followup-To: comp.lang.c++
  6. Date: 12 Jan 1996 18:19:09 GMT
  7. Organization: SGI
  8. Message-ID: <AUSTERN.96Jan12101909@isolde.mti.sgi.com>
  9. References: <20c.32169.607@newage.com.ar> <4bsnbu$5mu@mujibur.inmind.com>
  10.     <30EDC013.7C780E5E@cims.nyu.edu> <DL1pqE.KKq@infosoft.com>
  11. Reply-To: austern@mti.sgi.com
  12. NNTP-Posting-Host: isolde.mti.sgi.com
  13. In-reply-to: jgalt@infosoft.com's message of Fri, 12 Jan 1996 03:58:32 GMT
  14.  
  15. In article <DL1pqE.KKq@infosoft.com> jgalt@infosoft.com (John Galt) writes:
  16.  
  17. > I beg to differ.  Name mangling serves several indispensible functions:
  18. > 1.  It makes it possible to have more than one function with the same name
  19. > (differing in their argument lists).  To do this without mangling, the linker
  20. > would have to see not just a function name, or even class::name, but a full
  21. > _prototype_ for each function (omitting variable names and the result type).
  22. > 2.  It allows the linker to do error checking.  Example:  Module A calls
  23. > foo() in module B.  I change the definition of foo (and its argument list)
  24. > but forget to change A.  Without name mangling, the program will simply crash
  25. > (or do strange things because I've clobbered the stack...)
  26.  
  27. But that's just an artifact of today's (or rather yesterday's) linker
  28. technology.  Look at all the assumptions in those two paragraphs: that
  29. we're dealing with a compiler instead of an interpreter, that the
  30. compiler produces machine code instead of some intermediate-level
  31. description, that the only way to give a linker information about a
  32. function is through the function's name, and so on.
  33.  
  34. Name mangling works, even though it's not very elegant, and it can be
  35. used with ordinary linkers; that's why most C++ compilers use it.
  36. There's nothing in the C++ standard, though, that mandates it.
  37. There's no reason why a C++ compilation system can't have a more
  38. sophisticated notion of what a linker is.  More sophisticated linkers
  39. are probably a good idea anyway, because of templates.
  40.  
  41. Name mangling is an implementation detail, and, moreover, a detail
  42. that only applies to certain kinds of implementations.  It doesn't
  43. belong in the standard.
  44. -- 
  45. Matt Austern
  46. SGI: MTI Compilers Group
  47. austern@isolde.mti.sgi.com
  48.